package com.axzh.interview.designPattern;

public class Singleton {
	
	/**
	 * 第一种方式
	 */
	/*public final static Singleton INSTANCE = new Singleton();
	
	private Singleton() {
		
	}*/
	
	/**
	 * 第二种方式
	 */
	/*private static Singleton instance = new Singleton(); 
	
	private Singleton() {
		
	}
	
	public Singleton getInstance() {
		return instance;
	}*/
	
	/**
	 * 第三种方式
	 */
	/*private static Singleton instance = null;
	
	private Singleton() {
		
	}
	
	public synchronized Singleton getInstance() {
		if(instance == null) {
			return new Singleton();
		} else {
			return instance;
		}
	}*/
	
	/**
	 * 第四种方式
	 */
	/*private static Singleton instance = null;
	
	private Singleton() {
		
	}
	
	public Singleton getInstance() {
		if(instance == null) {
			synchronized(this) {
				if(instance == null) {
					return new Singleton();
				} else {
					return instance;
				}
			}
		} else {
			return instance;
		}
	}*/
	
	/**
	 * 第五种方式
	 */
	/*public enum Singleton {
		INSTACE;
		
		//Elvis() {
		//}
		
		public void function() {
			
		}
	}*/
}
